package Leetcode;

import java.util.HashMap;
import java.util.Map;

/**
 * @ Author     ：侯耀祖
 * @ Description：
 */
public class firstMissingPositive {
    public int firstMissingPositive(int[] nums) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int num : nums) {
            map.put(num, map.getOrDefault(num, 0) + 1);
        }
        for (int i = 1; i < Integer.MAX_VALUE; i++) {
            if (!map.containsKey(i)){
                return i;
            }
        }
        return 1;
    }
}
